PHP Tutorial
This type of strings does not processes special characters inside quotes.
<?php
$x = 'Code Always';
echo $x;
?>
Single-quotes strings in PHP does not processes special characters.
Unlike single-quote strings, double-quote strings in PHP is capable of processing special characters.
<?php
$x = 'Code Always';
echo $x;
echo "Welcome to $x";
?>
In PHP the character beginning with a backslash(“\”) are treated as escape sequences and are replaced with special characters. Here are few important escape sequences.
<?php
$x = 'Code Always.';
echo $x;
echo "Welcome to $x \n";
echo "$x ";
?>
Welcome to Code Always.
Code Always.
Built-in functions in PHP are some existing library functions which can be used directly in our programs making an appropriate call to them
The PHP strlen() function returns the length of a string.
<?php
echo strlen("Code Always.");
?>
The output of the above PHP code is '12'.
The PHP strrev() function reverses a string.
<?php
echo strrev("Code Always.");
?>
The output of the above PHP code is '.syawlA edoC'.
The PHP strpos() function searches for a specific text within a string.
<?php
echo strpos("Code Always.","Always");
?>
The output of the above PHP code is '6'.
The PHP str_replace() function replaces some characters with some other characters in a string.
<?php
echo str_replace("Now","Always","Code Now.");
?>
The output of the above PHP code is 'Code Always.'.
NOTE - Built-in string functions is given in function reference PHP String Functions